package com.flyduck.vueshop.user.remote.controller;

import com.flyduck.vueshop.common.core.lang.Result;
import com.flyduck.vueshop.common.sotoken.annotation.InnerAuth;
import com.flyduck.vueshop.user.remote.service.RemoteAddressService;
import com.flyduck.vueshop.user.vo.RemoteAddressRespVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * AppUserApiController
 * </p>
 *
 * @author flyduck
 * @since 2024-07-10
 */
@RestController
@RequestMapping("/user/remote/address")
public class RemoteAddressController {

    @Resource
    private RemoteAddressService remoteAddressService;

    @InnerAuth
    @GetMapping("/getDefaultAddressByUserId/{userId}")
    Result<RemoteAddressRespVO> getDefaultAddressByUserId(@PathVariable("userId") Long userId){
        RemoteAddressRespVO remoteAddressRespVO = remoteAddressService.getDefaultAddressByUserId(userId);
        return Result.success(remoteAddressRespVO);
    }

    @InnerAuth
    @GetMapping("/getAddressById/{id}")
    public Result<RemoteAddressRespVO> getAddressById(@PathVariable("id") Long id){
        RemoteAddressRespVO remoteAddressRespVO = remoteAddressService.getAddressById(id);
        return Result.success(remoteAddressRespVO);
    }
}
